#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

typedef char ElementType;
typedef struct _stack{
    ElementType elm;
    struct _stack *next;
} stack;

stack *stackInit();
bool  stackEmpty(stack* s);
void  push(stack *s,ElementType e);
ElementType pop(stack *s);

char matchTable[128]={
    [')'] = '(',
    [']'] = '[',
    ['}'] = '{'
};

stack *stackInit(){
    stack *s=malloc(sizeof(stack));
    s->next=NULL;
    return s;
}
bool  stackEmpty(stack* s){
    return (s->next==NULL);
}
void  push(stack *s,ElementType e){
    stack *new=malloc(sizeof(stack));
    new->elm=e;
    new->next=s->next;
    s->next=new;
    return;
}
ElementType pop(stack *s){
    stack *tmp=s->next;
    ElementType r=tmp->elm;
    s->next=tmp->next;
    free(tmp);
    return r;
}

bool isValid(char* s) {
    stack *st=stackInit();
    char c;
    while( (c=*s) != '\0' ){
        if( c=='(' || c=='[' || c=='{' )
            push(st,c);
        else
            if( stackEmpty(st) || matchTable[c] != pop(st) )
                return false;
        s++;
    }
    if( stackEmpty(st) )
        return true;
    return false;;
}

int main(){
    if( isValid("{}{}{}[[{}{}{{}}{([])}[]]]") )
        printf("yes\n");
    else
        printf("no\n");
    return 0;
}
